<?php
/*
 * Hook funkce systému Drupal, zajišťuje přidání/odebrání položek práv mezi nastavení Drupalu.
 * Je spuštěna při aktivaci/deaktivaci modulu
 */
function mailcontent_perm() {
    return array(
        t('synchronization menu'),
        t('content user'),
        t('content edit'),
        t('settings accounts'),
        t('settings roles'),
        t('settings actions'),
        t('settings advanced')
        ); 
}//OK

/*
 * Hook funkce systému Drupal, zajišťuje vytvoření callbacků a položek menu
 * Je spouštěna jen při aktivaci/deaktivaci modulu
 */
function mailcontent_menu() {
    /* Nastavení - jenotlivé položky - vlastní položky v menu */    
    $items['mailcontent/settings'] = array(
            'page callback' => 'mailcontent_settings',
            'type' => MENU_NORMAL_ITEM,
            'title' => t('Mailcontent Settings'),
            'access arguments' => array('settings accounts'),
    );
    $items['mailcontent/settings/accounts'] = array(
            'page callback' => 'mailcontent_settings_accounts',
            'type' => MENU_NORMAL_ITEM,
            'title' => t('Accounts'),
            'access arguments' => array('settings accounts'),
    );
    $items['mailcontent/settings/mailboxes'] = array(
            'page callback' => 'mailcontent_settings_mailboxes',
            'type' => MENU_NORMAL_ITEM,
            'title' => t('Mailboxes'),
            'access arguments' => array('settings accounts'),
    );
    $items['mailcontent/settings/actions'] = array(
            'page callback' => 'mailcontent_settings_actions',
            'type' => MENU_NORMAL_ITEM,
            'title' => t('Actions'),
            'access arguments' => array('settings actions'),
    );
    $items['mailcontent/settings/keywords'] = array(
            'page callback' => 'mailcontent_settings_keywords',
            'type' => MENU_NORMAL_ITEM,
            'title' => t('Keywords'),
            'access arguments' => array('settings actions'),
    );
    $items['mailcontent/settings/roles'] = array(
            'page callback' => 'mailcontent_settings_roles',
            'type' => MENU_NORMAL_ITEM,
            'title' => t('Roles'),
            'access arguments' => array('settings roles'),
    );
    $items['mailcontent/settings/others'] = array(
            'page callback' => 'mailcontent_settings_others',
            'type' => MENU_NORMAL_ITEM,
            'title' => t('Others - advanced'),
            'access arguments' => array('settings actions')
    );
    /* Zobrazení tabulek s kontentem - zvlášť schůzky, maily, články a úkoly - vlastní položka v menu */
    $items['mailcontent/content'] = array(
            'page callback' => 'mailcontent_content',
            'type' => MENU_NORMAL_ITEM,
            'title' => t('Mailcontent Content'),
            'access arguments' => array('content user'),
    );
    $items['mailcontent/content/article/all'] = array(
            'page callback' => 'mailcontent_content_article',
            'type' => MENU_NORMAL_ITEM,
            'title' => t('Articles'),
            'access arguments' => array('content user'),
    );
    $items['mailcontent/content/inquiry/all'] = array(
            'page callback' => 'mailcontent_content_inquiry',
            'type' => MENU_NORMAL_ITEM,
            'title' => t('Inquries'),
            'access arguments' => array('content user'),
    );
    $items['mailcontent/content/schedule/all'] = array(
            'page callback' => 'mailcontent_content_schedule',
            'type' => MENU_NORMAL_ITEM,
            'title' => t('Schedules'),
            'access arguments' => array('content user'),
    );
    $items['mailcontent/content/task/all'] = array(
            'page callback' => 'mailcontent_content_task',
            'type' => MENU_NORMAL_ITEM,
            'title' => t('Tasks'),
            'access arguments' => array('content user'),
    );

    /* Synchronizace mailu - vlastní položka v menu*/
    $items['mailcontent/synchro'] = array(
            'page callback' => 'mailcontent_synchro',
            'type' => MENU_NORMAL_ITEM,
            'title' => t('Mailcontent Synchronization'),
            //    'menu_name' => 'Mailcontent',
            'access arguments' => array('synchronization menu'),
    );

    /* Editace loginu - callback*/
    $items['mailcontent/editlogin'] = array(
            'page callback' => 'mailcontent_editlogin',
            'type' => MENU_CALLBACK,
            'title' => t('Mailcontent edit account'),
            'access arguments' => array('settings accounts'),
    );

    /* Mazani loginu - callback*/
    $items['mailcontent/dellogin'] = array(
            'page callback' => 'mailcontent_dellogin',
            'type' => MENU_CALLBACK,
            'title' => t('Mailcontent - delete account'),
            'access arguments' => array('settings accounts'),
    );
    /* Editace role - callback*/
    $items['mailcontent/editrole'] = array(
            'page callback' => 'mailcontent_editrole',
            'type' => MENU_CALLBACK,
            'title' => t('Mailcontent edit role'),
            'access arguments' => array('settings roles'),
    );

    /* Mazani loginu - callback*/
    $items['mailcontent/delrole'] = array(
            'page callback' => 'mailcontent_delrole',
            'type' => MENU_CALLBACK,
            'title' => t('Mailcontent - delete role'),
            'access arguments' => array('settings roles'),
    );
    /* Mazani akce - callback*/
    $items['mailcontent/editaction'] = array(
            'page callback' => 'mailcontent_editaction',
            'type' => MENU_CALLBACK,
            'title' => t('Mailcontent edit action'),
            'access arguments' => array('settings actions'),
    );

    /* Mazani loginu - callback*/
    $items['mailcontent/delaction'] = array(
            'page callback' => 'mailcontent_delaction',
            'type' => MENU_CALLBACK,
            'title' => t('Mailcontent - delete action'),
            'access arguments' => array('settings actions'),
    );

    /* Editace mail adresy - callback*/
    $items['mailcontent/editmailaddress'] = array(
            'page callback' => 'mailcontent_editmailaddress',
            'type' => MENU_CALLBACK,
            'title' => t('Mailcontent edit mailaddress rule'),
            'access arguments' => array('settings accounts'),
    );

    /* Mazání mail adresy - callback*/
    $items['mailcontent/delmailaddress'] = array(
            'page callback' => 'mailcontent_delmailaddress',
            'type' => MENU_CALLBACK,
            'title' => t('Mailcontent - delete mailaddress rule'),
            'access arguments' => array('settings accounts'),
    );
    /* Mazání klíčového slova - callback*/
    $items['mailcontent/delkeyword'] = array(
            'page callback' => 'mailcontent_delkeyword',
            'type' => MENU_CALLBACK,
            'title' => t('Mailcontent - delete keyword'),
            'access arguments' => array('settings actions'),
    );
    /* Editace klíčového slova - callback*/
    $items['mailcontent/editkeyword'] = array(
            'page callback' => 'mailcontent_editkeyword',
            'type' => MENU_CALLBACK,
            'title' => t('Mailcontent - delete keyword'),
            'access arguments' => array('settings actions'),
    );
    /* Mazání z tabulky servis - callback*/
    $items['mailcontent/delother'] = array(
            'page callback' => 'mailcontent_delother',
            'type' => MENU_CALLBACK,
            'title' => t('Mailcontent - delete value from service table'),
            'access arguments' => array('settings actions')
    );
    /* Editace tabulky servis - callback*/
    $items['mailcontent/editother'] = array(
            'page callback' => 'mailcontent_editother',
            'type' => MENU_CALLBACK,
            'title' => t('Mailcontent edit value from service table'),
            'access arguments' => array('settings actions')
    );
    /* Přechod na určitý článek - callback*/
    $items['mailcontent/gotonode'] = array(
            'page callback' => 'mailcontent_gotonode',
            'type' => MENU_CALLBACK,
            'title' => t('Mailcontent - callback for link to node section'),
            'access arguments' => array('access content')
    );
    /* Mazání mailboxu - callback*/
    $items['mailcontent/delmail'] = array(
            'page callback' => 'mailcontent_delmail',
            'type' => MENU_CALLBACK,
            'title' => t('Mailcontent - delete mail from database'),
            'access arguments' => array('settings accounts')
    );
    /* Publikace článku - callback*/
    $items['mailcontent/publish'] = array(
            'page callback' => 'mailcontent_publish',
            'type' => MENU_CALLBACK,
            'title' => t('Mailcontent - publish article'),
            'access arguments' => array('content edit')
    );
    /* Zobrazení ankety - callback*/
    $items['mailcontent/inquiry_view'] = array(
            'page callback' => 'mailcontent_view_iquiry',
            'type' => MENU_CALLBACK,
            'title' => t('Mailcontent - view inquiry'),
            'access arguments' => array('content edit')
    );
    /* Zobrazení příchozího mailu - callback*/
    $items['mailcontent/view'] = array(
            'page callback' => 'mailcontent_view_mail',
            'type' => MENU_CALLBACK,
            'title' => t('Mailcontent - view received mail'),
            'access arguments' => array('content user')
    );
    $items['mailcontent/delnode'] = array(
            'page callback' => 'mailcontent_delnode_for_mail',
            'type' => MENU_CALLBACK,
            'title' => t('Mailcontent - delete node from database'),
            'access arguments' => array('content edit')
    );


    return $items;
}//OK

/*
 * Hook funkce systému Drupal, volá se pokaždé, když je vykonáván skript cron.php
 *
 */
function mailcontent_cron(){ 
    mailcontent_db_add_log(t('Automatic synchronization of mailboxes'), 'info');
    mailcontent_synchro();
} //OK

?>
